import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
// 按需引入组件
import AutoImport from "unplugin-auto-import/vite";
import Components from "unplugin-vue-components/vite";
import { ElementPlusResolver } from "unplugin-vue-components/resolvers";
import { fileURLToPath, URL } from "url";

// https://vitejs.dev/config/
export default defineConfig({
  base: "/manageSystem/",
  build: {
    outDir: "manageSystem", // 指定输出目录
  },
  plugins: [
    vue(),
    AutoImport({
      resolvers: [ElementPlusResolver()],
    }),
    Components({
      resolvers: [ElementPlusResolver()],
    }),
  ],
  // 定义全局变量
  resolve: {
    alias: {
      "@": fileURLToPath(new URL("./src", import.meta.url)),
    },
  },
  // 服务启动配置项
  server: {
    proxy: {
      "/api": {
        target: "https://bx419118jm56.vicp.fun/",
        changeOrigin:true,
        // rewrite: (path) => path.replace(/^\/api/, '')     
       },
    },
  },
});
